package com.controller;

import com.entity.Blog;
import com.entity.User;
import com.service.impl.SearchServiceImpl;
import com.service.intf.SearchService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class SearchServlet extends BaseServlet {
    private SearchService searchService=new SearchServiceImpl();
    protected void searchUserAndBlog(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String searchValue = req.getParameter("searchValue");
        req.getSession().setAttribute("searchValue",searchValue);
        List<Blog> blogs = searchService.searchBlog(searchValue);
        req.getSession().setAttribute("blogs",blogs);
        List<User> users = searchService.searchUser(searchValue);
        req.getSession().setAttribute("users",users);
        req.getRequestDispatcher("/pages/search/search.jsp").forward(req,resp);


    }

}
